home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / CLAPP.CPP < prev    next >
C/C++ Source or Header  |  1993-08-26  |  8KB  |  249 lines

  1. //----------------------------------------------------------------------------
  2. //                            MODULE DESCRIPTION
  3. //
  4. //  Module:    clapp.cpp
  5. //   Title:    C++ Class Libraries
  6. //  Notice:    John M. Weeder
  7. //                 Copyright (c) 1993. All rights reserved.
  8. //             This module contains proprietary information and should be 
  9. //                treated as confidential.
  10. //
  11. //----------------------------------------------------------------------------
  12. //                           MAINTENANCE HISTORY
  13. //
  14. // $Workfile$
  15. // $Revision$
  16. //   $Author$
  17. //     $Date$
  18. //      $Log$    
  19. //
  20. //----------------------------------------------------------------------------
  21. //                             MODULE NARRATIVE
  22. //
  23. //    This module contains code for the class CL_APP.
  24. //
  25. //    The code in this module may be written in C++ or C.
  26. //
  27. //    This module is portable to:
  28. //        DOS 3.X+
  29. //        MS Windows 3.X+
  30. //        OS/2 2.X+
  31. //        OS/2 2.0 PM
  32. //
  33. //    The following compilers are supported:
  34. //        MSC 6.0A
  35. //        MSC/C++ 7.0
  36. //        Borland C++ 3.1 for DOS
  37. //        Borland C++ 1.0 for OS/2 2.X
  38. //
  39. //----------------------------------------------------------------------------
  40. #include <class.hpp>
  41.  
  42.  
  43. //----------------------------------------------------------------------------
  44. //   Description:    Default constructor
  45. //    Parameters:
  46. //       Returns:    
  47. //----------------------------------------------------------------------------
  48. FN_M CL_APP::CL_APP()
  49. {
  50.     CL_APP::Initialize(CL_INIT_CLASS);
  51. }
  52.  
  53.  
  54. //----------------------------------------------------------------------------
  55. //   Description:    Copy constructor
  56. //    Parameters:    rccl_app        Reference to object to copy.
  57. //       Returns:    
  58. //----------------------------------------------------------------------------
  59. FN_M CL_APP::CL_APP(RCCL_APP rccl_app)
  60. {
  61.     CL_APP::Initialize(CL_INIT_CLASS);
  62.     *this = rccl_app;
  63. }
  64.  
  65.  
  66. //----------------------------------------------------------------------------
  67. //   Description:    Destructor
  68. //    Parameters:
  69. //       Returns:    
  70. //----------------------------------------------------------------------------
  71. FN_M CL_APP::~CL_APP()
  72. {
  73.     CL_APP::Destroy(FALSE);
  74. }
  75.  
  76.  
  77. //----------------------------------------------------------------------------
  78. //   Description:    Destroy object. Free any resources used by object.
  79. //                          Normally called by destructor.
  80. //                        Should allow multiple calls from various classes.
  81. //    Parameters:    fDestroyAll        Destroy parents also?
  82. //                                            Default is TRUE.
  83. //       Returns:    TRUE if successful.
  84. //----------------------------------------------------------------------------
  85. BOOL FN_M CL_APP::Destroy(BOOL fDestroyAll)
  86. {
  87.     CL_APP::Initialize(CL_INIT_CLASS_VARS);
  88.     if (fDestroyAll)                            // Destroy parent.
  89.         CL_APP_PARENT::Destroy(fDestroyAll);                    
  90.     return TRUE;
  91. }
  92.  
  93.  
  94. //----------------------------------------------------------------------------
  95. //   Description:    Initialize object. 
  96. //                          Normally called by constructor.
  97. //                        Should allow multiple calls from various classes.
  98. //    Parameters:    sInit        Initialization code. May be one of the following:
  99. //                                        CL_INIT_CLASS            Reset class variables and
  100. //                                                                    and dynamic allocations for
  101. //                                                                    this class only.
  102. //                                        CL_INIT_CLASS_VARS    Reset class variables for
  103. //                                                                    this class only.
  104. //                                        CL_INIT_VARS            Reset class variables for
  105. //                                                                    this class only.
  106. //                                        CL_INIT_ALL                Initialize class and all 
  107. //                                                                    parent class, including
  108. //                                                                    dynamic memory allocation.
  109. //                                    Default is CL_INIT_ALL
  110. //       Returns:    TRUE if successful.
  111. //----------------------------------------------------------------------------
  112. BOOL FN_M CL_APP::Initialize(SHORT sInit)
  113. {
  114.     if (sInit == CL_INIT_VARS || sInit == CL_INIT_ALL)
  115.         CL_APP_PARENT::Initialize(sInit);
  116.  
  117.     return TRUE;
  118. }
  119.  
  120.  
  121. //----------------------------------------------------------------------------
  122. //   Description:    Assignment operator
  123. //                          NOTE: Don't copy object into self
  124. //    Parameters:    rccl_app        Reference to right value.
  125. //       Returns:    Reference to new object.
  126. //----------------------------------------------------------------------------
  127. RCCL_APP FN_M CL_APP::operator=(RCCL_APP rccl_app)
  128. {
  129.     if (this != &rccl_app)
  130.         {
  131.         Invalid("CL_APP::operator=");
  132.         }
  133.     return (RCCL_APP)*this;
  134. }
  135.  
  136.  
  137. //----------------------------------------------------------------------------
  138. //   Description:    Retrieve object from persistent storage
  139. //    Parameters:    pcsz        Name of object.
  140. //                        pcszSub    Sub-name of object.
  141. //                                    The first character of the name should be '~'.
  142. //                                    If NULL, no sub name is available.
  143. //                                    Default is NULL
  144. //       Returns:    TRUE if successful.
  145. //----------------------------------------------------------------------------
  146. BOOL FN_M CL_APP::Retrieve(PCSZ pcsz, PCSZ pcszSub)
  147. {
  148.     Assert(pcsz);
  149.                                                     // Create sub-name for object
  150.     CL_STRING string("%s~CL_APP", (pcszSub ? pcszSub: ""));
  151.     if (string.IsError())
  152.         return FALSE;
  153.                                                     // Get parent
  154.     if (!CL_APP_PARENT::Retrieve(pcsz, (PCSZ)string))
  155.         return FALSE;
  156.  
  157.     return !IsError();
  158. }
  159.  
  160.  
  161. //----------------------------------------------------------------------------
  162. //   Description:    Store object to persistent storage
  163. //    Parameters:    pcsz        Name of object.
  164. //                        pcszSub    Sub-name of object.
  165. //                                    The first character of the name should be '~'.
  166. //                                    If NULL, no sub name is available.
  167. //                                    Default is NULL
  168. //       Returns:    TRUE if successful.
  169. //----------------------------------------------------------------------------
  170. BOOL FN_M CL_APP::Store(PCSZ pcsz, PCSZ pcszSub)
  171. {
  172.     Assert(pcsz);
  173.     if (IsError())                                // Check that object is valid
  174.         return FALSE;
  175.                                                     // Create sub-name for object
  176.     CL_STRING string("%s~CL_APP", (pcszSub ? pcszSub: ""));
  177.     if (string.IsError())
  178.         return FALSE;
  179.                                                     // Store parent
  180.     if (!CL_APP_PARENT::Store(pcsz, (PCSZ)string))
  181.         return FALSE;
  182.  
  183.     return !IsError();
  184. }
  185.  
  186.  
  187. //----------------------------------------------------------------------------
  188. //   Description:    Print object value to debugging output.
  189. //    Parameters:    pccl_app        Pointer to dynamic object. 
  190. //                                    If NULL, static data elements are printed.
  191. //                                    Default is NULL.
  192. //                        pcsz        Name of object.
  193. //                                    If NULL, no name is displayed.
  194. //                                    Default is NULL.
  195. //                        cLevel    Display level. 
  196. //                                    Default is zero.
  197. //       Returns:
  198. //----------------------------------------------------------------------------
  199. #if COMPILE_DEBUG
  200. VOID FN_M CL_APP::Print(PCCL_APP pccl_app, PCSZ pcsz, SIZET cLevel)
  201. {
  202. #if COMPILE_TEST
  203.     OutputL(cLevel, "CL_APP%s%s", (pcsz?"::":""), (pcsz?pcsz:""));
  204.     cLevel++;
  205.     if (pccl_app)
  206.         {
  207.         Output(" <%p>\n", pccl_app);
  208.         if(!pccl_app->IsError())
  209.             {
  210. //            OutputL(cLevel, " = %d\n", pccl_app->);
  211.             }
  212.         }
  213.     else
  214.         Output(" <NULL>\n");
  215.     CL_APP_PARENT::Print((CL_APP_PARENT _FAR_ *)pccl_app, pcsz, cLevel);
  216.     return ;
  217. #else
  218.     NOTUSED(cLevel);
  219.     NOTUSED(pccl_app);
  220.     NOTUSED(pcsz);
  221.     return ;
  222. #endif
  223. }
  224. #endif
  225.  
  226.  
  227. //----------------------------------------------------------------------------
  228. //   Description:    Run standard test suite on object.
  229. //    Parameters:    sTest        Test to run.
  230. //                                    If 0, run default tests.
  231. //                                    Default is 0.
  232. //       Returns:    TRUE if successful.
  233. //----------------------------------------------------------------------------
  234. #if COMPILE_DEBUG
  235. BOOL FN_M CL_APP::Test(SHORT sTest)
  236. {
  237. #if COMPILE_TEST
  238.     NOTUSED(sTest);
  239.     return TRUE;
  240. #else
  241.     NOTUSED(sTest);
  242.     return TRUE;
  243. #endif
  244. }
  245. #endif
  246. //----------------------------------------------------------------------------
  247. //------------------------------- End of File --------------------------------
  248. //----------------------------------------------------------------------------
  249.